package com.fenghongzhang.day012;

import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

//网络单例
public class HttpUtil {

    private static HttpUtil httpUtil;

    private  Retrofit retrofit;

    private  HttpUtil(){
    }
    public static synchronized HttpUtil getHttpUtil(){
        if(httpUtil == null){
           httpUtil = new HttpUtil();
        }
        return httpUtil;
    }


    public  synchronized Retrofit getRetrofit(){
        if (retrofit == null) {
            retrofit = new Retrofit.Builder().baseUrl("http://")
                    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                    .addConverterFactory(GsonConverterFactory.create())
                    .build();
            return retrofit;
        }
        return retrofit;
    }

}
